﻿using assignment2.Entity;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace assignment2.Entity
{
    public class CreditAccount : Account
    {
        public double Credit { get; set; }
        public CreditAccount(string id, string password, double balance,double credit) : base(id, password, balance)
        {
            this.Credit = credit;
        }
        public CreditAccount()
        {

        }
        public double GetBalance()
        {
            return Balance;
        }
        public override void Withdraw(double amount)
        {
            if (Credit < 60)
            {
                throw new ArgumentException("信誉分低，暂时不支持取钱，请联系柜台人员");
            }
            else
            {
                if (amount > 0 && amount <= Balance)
                {
                    Balance -= amount;
                }
                else
                {
                    throw new ArgumentException("取款金额必须大于0且不超过余额");
                }
            }
        } 
    }
}
